label: Compute label baselines correctly
authorBenjamin Otte <otte@redhat.com>
Sun, 8 Dec 2019 04:32:35 +0000 (05:32 +0100)
committerBenjamin Otte <otte@redhat.com>
Mon, 9 Dec 2019 15:35:41 +0000 (16:35 +0100)
When we were switching smallest and widest, we were not switching the
baselines.

gtk/gtklabel.c

index def048a7db0ad5eb85cae1d3841e7329812e0789..ad79305be637bcd3f7c53a6fe66a84d5bf211b44 100644 (file)
@@ -3630,14 +3630,24 @@ gtk_label_get_preferred_size (GtkWidget      *widget,
     }
   else /* GTK_ORIENTATION_VERTICAL */
     {
-      *minimum_size = MIN (smallest_rect.height, widest_rect.height);
-      *natural_size = MAX (smallest_rect.height, widest_rect.height);
-
-      if (minimum_baseline)
-        *minimum_baseline = smallest_baseline;
-
-      if (natural_baseline)
-        *natural_baseline = widest_baseline;
+      if (smallest_rect.height < widest_rect.height)
+        {
+          *minimum_size = smallest_rect.height;
+          *natural_size = widest_rect.height;
+          if (minimum_baseline)
+            *minimum_baseline = smallest_baseline;
+          if (natural_baseline)
+            *natural_baseline = widest_baseline;
+        }
+      else
+        {
+          *minimum_size = widest_rect.height;
+          *natural_size = smallest_rect.height;
+          if (minimum_baseline)
+            *minimum_baseline = widest_baseline;
+          if (natural_baseline)
+            *natural_baseline = smallest_baseline;
+        }
     }
 }